﻿Public Class Test_CheckICMP
    Private WithEvents X As New PurpleKnife.Library.CheckICMP

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Try
            X.Timeout = Integer.Parse(txtTimeout.Text)
            X.PingCount = Integer.Parse(txtCount.Text)
            X.TTL = Integer.Parse(txtTTL.Text)
            X.DontFragment = (chkDontFragment.Checked = True)
            X.PingData = txtData.Text
            X.PerformTest(System.Net.IPAddress.Parse(txtIP.Text))
        Catch ex As Exception
            MsgBox("Exception (" & ex.Message & ") occured.")
        End Try
    End Sub

    Private Sub X_CheckCompleted(sender As Object, e As Library.CheckICMP.CheckCompletedEventArgs) Handles X.CheckCompleted
        MsgBox("Target IP (" & e.Target.ToString & "):" & vbCrLf & vbCrLf & "Sent (" & e.PingCount & ") ICMP echo requests, received (" & e.RoundTripTimes.Count & ") replies." & vbCrLf & "Average RTT is (" & e.AverageRTT & "ms), packet loss is (" & e.PacketLoss & "%).")
    End Sub

End Class
